from appium.webdriver.common.appiumby import AppiumBy

from Page.base_page import AppBasePage


class MinePage(AppBasePage):

    def __init__(self):
        super().__init__()

    # 登录
    def go_login(self, username, password):
        self.find_el(*(AppiumBy.ID, 'com.tpshop.malls:id/head_img')).click()
        # 输入账号密码
        self.find_el(*(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("请输入账号")')).send_keys(username)
        self.find_el(*(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("请输入密码")')).send_keys(password)
        # 勾选协议
        self.find_el(*(AppiumBy.CLASS_NAME, 'android.widget.Button')).click()
        # time.sleep(2)
        # 点击登录
        self.find_el(*(AppiumBy.XPATH, '//android.widget.TextView[@resource-id="com.tpshop.malls:id/login_tv"]')).click()

    # 我的订单
    def go_my_order(self):
        self.find_el(*(AppiumBy.ID, 'com.tpshop.malls:id/all_order_view')).click()

